﻿using SEIPropertyDataService.Entity.Converters;
using SqlSugar;
using System;
using System.Text.Json.Serialization;

namespace SEIPropertyDataService.Entity.Models
{
    /// <summary>
    /// 用户
    /// </summary>
    //[Tenant("AccountDb")]
    [SugarTable("user")]
    public class UserModel
    {
        /// <summary>
        /// id
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, ColumnName = "uuid", SqlParameterDbType = typeof(KingbaseUuidConverter))]
        public string Id { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "用户名", ColumnName = "user_account")]
        public string Account { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "password", ColumnDescription = "密码", Length = 350)]
        public string Password { get; set; }
        /// <summary>
        /// 手机号
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnName = "tel", Length = 20, ColumnDescription = "手机号")]
        public string Phone { get; set; }
        /// <summary>
        /// 邮箱
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnName = "email", ColumnDescription = "邮箱")]
        public string Email { get; set; }
        /// <summary>
        /// 用户姓名
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "user_name", Length = 30, ColumnDescription = "用户姓名")]
        public string UserName { get; set; }
        /// <summary>
        /// 公司/组织机构
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "user_company", Length = 50, ColumnDescription = "公司/组织机构")]
        public string Organization { get; set; }
        /// <summary>
        /// 注册时间
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "create_date", ColumnDescription = "注册时间", IsOnlyIgnoreUpdate = true)]
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "modify_date", ColumnDescription = "更新时间")]
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 是否锁定
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "is_locked", DefaultValue = "false", ColumnDescription = "是否锁定")]
        public bool IsLocked { get; set; } = false;
        /// <summary>
        /// 是否有效
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnName = "valid_flag", DefaultValue = "true", ColumnDescription = "是否有效")]
        public bool IsValid { get; set; } = true;
    }
}
